package com.example.concurrent.chapter01;

/**
 * @author Create By Liuqz
 * @date 2018/11/19 10:22
 */
public class TemplateMethod {

    //类似于Thrad.start()方法
    public final void print(String message) {
        System.out.println("################");
        wrapPrint(message);
        System.out.println("################");
    }

    //类似于Thread.run() 方法
    protected void wrapPrint(String message) {

    }

    public static void main(String[] args) {
        TemplateMethod t1 = new TemplateMethod(){
            @Override
            protected void wrapPrint(String message) {
                System.out.println("*"+message+"*");
            }
        };

        t1.print("Hello Thread");

        TemplateMethod t2 = new TemplateMethod(){
            @Override
            protected void wrapPrint(String message) {
                System.out.println("*"+message+"*");
            }
        };
        t2.print("Hello Thread");

    }
}
